﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="visualedit.aspx.cs" Inherits="Crm_visualedit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        * { margin: 0; padding: 0; }
    </style>

    <script src="../js/jquery-1.4.4.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function()
        {
            ReLoad();
            var $iframe = $('#frame1');
            $iframe.load(function()
            {
                $(this).contents().find("body").append($("#hidtext").html());
                $(this).height($(this).contents().find("body").height() + 400);
                $(this).contents().find("body").css("overflow-y", "hidden");
                attachFile("frame1", "/js/visualedit.js?"+Math.random(), "js");
            })
            $("#droppage").change(function()
            {
                $("#frame1").attr("src", $(this).val());
            });
        });
        function ReLoad()
        {            
            $("#frame1").attr("src", $("#droppage").val());
        }
        function attachFile(iframeId, filename, filetype)
        {
            var head = window.frames[iframeId].document.getElementsByTagName('body').item(0);
            if (filetype == "css")
            { //判断文件类型 
                var fileref = window.frames[iframeId].document.createElement("link");
                fileref.setAttribute("rel", "stylesheet");
                fileref.setAttribute("type", "text/css");
                fileref.setAttribute("href", filename);
            }
            if (filetype == "js")
            { //判断文件类型 
                var fileref = window.frames[iframeId].document.createElement('script'); //创建标签 
                fileref.setAttribute("type", "text/javascript"); //定义属性type的值为text/javascrip
                fileref.setAttribute("language", "JavaScript");
                fileref.setAttribute("src", filename); //文件的地址 
            }
            if (typeof fileref != "undefined")
                head.appendChild(fileref);
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div style="text-align:center;padding:20px;">
        请输入模板地址:<asp:DropDownList ID="droppage" runat="server" DataTextField="key" DataValueField="value">      
        </asp:DropDownList>  <input onclick="window.open(document.getElementById('droppage').value);" type="button" value="预览当前页"/>
    </div>
    <div id="loadhtml">
        <iframe id="frame1" name="frame1" width="100%" frameborder="0" src="/?fn=index">
        </iframe>
    </div>
    <div id="hidtext" style="display: none;">
        <style type="text/css">
            input.text { background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #C0C0C0; height: 16px; margin: 2px 0; padding: 5px 2px; }
            .lyb_yeji_note .yeji_note .btn input.tj_btn { background: url("images/btn_tjly.jpg") no-repeat scroll 0 0 transparent; border: 0 none; cursor: pointer; height: 25px; width: 66px; }
            .drag_operate_box { border: #719BC5 1px solid; font-size: 12px;position: absolute; z-index: 999999; }
            .drag_handle_box { background: #5575AF none repeat scroll 0 0; color: #FFFFFF; line-height: 20px; position: relative; white-space: nowrap; }
            .drag_handle_box .visual_edit, .drag_handle_box .op_delete { cursor: pointer; margin: 2px; text-align:right;}
            .drag_handle_box span { display: block; color: #FFF; }
        </style>
        <div id="drag_operate_box" class="drag_operate_box" style="visibility: visible; left: 0px;
            top: 0px; height: 0px; right: 0px; bottom: 0px; display: none;">
            <div class="drag_handle_box">
                <table width="100%" cellspacing="0" cellpadding="0">
                    <tbody>
                        <tr>
                            <td>
                                <span class="visual_title" style="text-indent:10px;">goods</span>
                            </td>
                            <td width="40">
                                <span class="visual_edit"><a href="javascript:" style="color: White;">编辑</a></span>
                            </td>
                            <td width="40">
                                <span class="op_delete"><a href="javascript:" style="color: White">删除</a></span>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
